package study.nosql.redis.service.key_event;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyspaceEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
public class _1_KeyspaceListener extends KeyspaceEventMessageListener {

    public _1_KeyspaceListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    @Override
    protected void doHandleMessage(Message message) {
        String channel = StrUtil.str(message.getChannel(), "UTF-8");
        String opType = StrUtil.str(message.getBody(), "UTF-8");

        log.info(">>>>>> channel= {}, op_type= {}", channel, opType);
    }
}
